const globalPackageConfig = require('./package-configs')

const packageConfig = {
  scripts: {},
  dependencies: {},
  devDependencies: {}
}

const addScripts = (script = {}) => {
  Object.assign(packageConfig.scripts, script)
}

const addDependencies = (dpd = {}) => {
  Object.assign(packageConfig.dependencies, dpd)
}

const addDevDependencies = (dpd = {}) => {
  Object.assign(packageConfig.devDependencies, dpd)
}

const genPackage = (api, options) => {
  addScripts(globalPackageConfig.base.scripts)
  addDependencies(globalPackageConfig.base.dependencies)
  addDevDependencies(globalPackageConfig.base.devDependencies)

  addScripts(globalPackageConfig.lowcode.scripts)
  addDependencies(globalPackageConfig.lowcode.dependencies)
  addDevDependencies(globalPackageConfig.lowcode.devDependencies)

  addDependencies({ '@hips/plugin-vue-i18n': '^1.0.0' })

  addDevDependencies({ less: '^4.1.2' })
  addDevDependencies({ 'less-loader': '^10.2.0' })

  api.extendPackage(pkg => {
    return packageConfig
  })
}

module.exports = genPackage
